/* 
 *  Created By: Mike Stevens
 *  Project URL: http://www.codeplex.com/sitesecuritymgmt
 *  License: GNU GPL v2
 *  Copyright (C) 2008 Mike Stevens
 * 
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using SiteSecurityManagement.Service;
using SiteSecurityManagement.Service.SharePoint;
using Microsoft.SharePoint;

namespace SiteSecurityManagement
{
    public partial class ResetInheritance : Page
    {
        #region Members
        private const string REDIRECTPAGE = "ssmu_editSecurity.aspx";
        #endregion

        #region Constructor/Destructor
        #endregion

        #region Properties
        #endregion

        #region Methods
        protected void btnSubmit_Click(object sender, EventArgs e)
        { 
            char pathSeperator=secTree.GetPathSeperator();

            //if no items were selected return a user error
            if (secTree.GetSelectedItems().Count == 0)
            {
                generalError.Text = this.GetGlobalResourceObject("ssmu","noSelectedTreeItems").ToString();
                return;
            }

            //for each selected node reset the inheritance
            foreach (TreeNode node in secTree.GetSelectedItems())
            {
                ResetInheritanceUtility.ResetInheritance(node, pathSeperator);
            }
            this.Context.Response.Redirect(SPContext.Current.Web.Url + "/_layouts/" + REDIRECTPAGE);
        }
        #endregion
    }
}
